
<?php 
// print_r($tab); 
?>

	<ul class="breadcrumb">
	  <li><a href="<?php echo $this->webroot;?>">Home</a> <span class="divider">/</span></li>
	  <li class="active"><?php echo __("Profilatura") ?></li>
	</ul>
	<div class="pull-right">
 		<a href='<?php echo $this->webroot;?>Info/refreshPermission' class="btn" ><?echo __("Aggiorna permessi")?> <i class='icon-refresh'></i></a>
	</div>

	<div class="tabbable"> 
	  <ul class="nav nav-tabs">
	    <li class='active'><a id="hTabAro" href="#tabAro" data-toggle="tab"><?echo __("Aro")?></a></li>
	    <li><a id="hTabAco" href="#tabAco" data-toggle="tab"><?echo __("Aco")?></a></li>
	    <li><a id="hTabPermessi" href="#tabPermessi" data-toggle="tab"><?echo __("Permessi")?></a></li>
	    <li><a id="htabDettaglioPermessi" href="#tabDettaglioPermessi" data-toggle="tab"><?echo __("Dettaglio Permessi")?></a></li>
	  </ul>
	  <div class="tab-content">
	    <div class="tab-pane active" id="tabAro">
			<ul>
				<?foreach($aros as $key=>$aro){?>
					<li>
						<?php echo $aro?>
					</li>
				<?}?>
			</ul>
	    </div>
	    <div class="tab-pane" id="tabAco">
	    	<div class="row-fluid">
		    	<div class="span6">
					<ul>
						<?foreach($acos as $key=>$aco){?>
							<li>
								<?php echo $aco?> <?php echo $this->Acl->link("<i class='icon-trash'></i>",array("controller" => "Profile", 'action' => 'deleteAco', $key), array('data-confirm'=>'true', 'escape'=>false)); ?>
							</li>
						<?}?>
					</ul>
		    	</div>
		    	<div class="span6">
					<form action="<?php echo $this->webroot;?>Profile/addAco" method="post" id="form">
					    <input type="hidden" name="tab" value="tabAco">
		    			<label><? echo __("Padre")?></label>
						<select name='Aco[parent_id]'>
							<option value=''></option>
							<?foreach($acos as $key=>$aco){?>
								<option value='<? echo $key?>' ><? echo $aco ?></option>
							<?}?>
						</select> 
					    <label><?php echo __("Aco") ?></label> 
					    <input type="text" name="Aco[alias]">
						<p>
							<button type="submit" class="btn btn-primary"><i class='icon-ok'></i></button>
						</p>
					</form>
		    	</div>
		    </div>
	    </div>
	    <div class="tab-pane" id="tabPermessi">
	    	
			<div class="row-fluid">
		    	<div class="span7">
	
				  <label><? echo __("Elenco")?></label>
	              <table class="table table-condensed table-bordered table-hover table-striped">
	                <thead>
	                  <tr>
					        <th><?php echo __("Id") ?></th>
					        <th><?php echo __("Aro") ?></th>
					        <th><?php echo __("Aco") ?></th>
					        <th><?php echo __("Crea") ?></th>
					        <th><?php echo __("Leggi") ?></th>
					        <th><?php echo __("Aggiorna") ?></th>
					        <th><?php echo __("Cancella") ?></th>
					        <th></th>
	                  </tr>
	                </thead>
	                <tbody>
						<?php foreach ($aros_acos as $value): ?> 
						<tr>
							<td><?php echo $value['aros_acos']['id']; ?></td>
							<td><?php echo $value['aros']['aro']; ?></td>
							<td><?php echo $value['acos']['aco']; ?></td> 
							<td><?php echo $value['aros_acos']['_create']; ?></td> 
							<td><?php echo $value['aros_acos']['_read']; ?></td> 
							<td><?php echo $value['aros_acos']['_update']; ?></td> 
							<td><?php echo $value['aros_acos']['_delete']; ?></td> 
							<td><?php echo $this->Acl->link("<i class='icon-trash'></i>",array("controller" => "Profile", 'action' => 'deleteAllowDeny', $value['aros_acos']['id']), array('data-confirm'=>'true', 'escape'=>false));  ?></td>
						</tr>
						<?php endforeach; ?>
						<?php unset($aros_acos); ?> 
	                </tbody>
	              </table>
	
		    	</div>
		    	<div class="span1">
		    	</div>
		    	<div class="span4">
					<form action="<?php echo $this->webroot;?>Profile/addAllowDeny" method="post" id="formAllowDeny">
					    <input type="hidden" name="tab" value="tabPermessi">
						<label><? echo __("Consenti / Nega")?></label>
						<select name="permesso">
						  <option value="allow">Consenti</option>
						  <option value="deny">Nega</option>
						</select>
		 
						<label><? echo __("Gruppo")?></label>
						<select name="azioni[]" multiple="multiple">
						  <option value="_create">Crea</option>
						  <option value="_read">Leggi</option>
						  <option value="_update">Aggiorna</option>
						  <option value="_delete">Cancella</option>
						</select>
						
						<label><? echo __("Gruppo / Utente")?></label>
						<select name='aro'>
							<option value=''></option>
							<?foreach ($aros as $key => $aro) {?>
						  			<option value='<? echo $key?>' ?><? echo $aro ?></option>
							<? } ?> 
						</select> 
					    <label><?php echo __("Aco") ?></label> 
						<select name='aco'>
							<option value=''></option>
							<?foreach ($acos as $key => $aco) {?>
						  			<option value='<? echo $key?>' ?><? echo $aco ?></option>
							<? } ?> 
						</select> 
						<p>
							<button type="submit" class="btn btn-primary"><i class='icon-ok'></i></button>
						</p>
					</form>
		    	</div>
		    </div>

	    </div>
	    <div class="tab-pane" id="tabDettaglioPermessi">
				<p>	
					<table id="table_permission" cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered">
					    <thead>
					        <tr>
					            <th><?echo __("Aco")?></th>
					            <th><?echo __("Valore")?></th>
					        </tr>
					    </thead>
					    <tbody>
							<?php foreach ($this->Session->read("permissions") as $permission => $value) { ?>
						        <tr>
						            <td><?php echo $permission ?></td>
						            <td><?php echo $value ?></td>
						        </tr>
							<?php } ?>
					    </tbody>
					</table>				
				</p>
	    </div>
	  </div>
	</div>
	<script>
		$(document).ready(function() {
			var tab2open = "<?php echo $tab; ?>";
			if(tab2open!=null){
				$("#"+tab2open).tab("show");			
			}
		});
		
	</script>


